/*
origin glsl source: 

                    precision mediump float;

                    attribute vec2 a_position;
                    attribute vec2 a_texCoord;
            
                    uniform vec4 tilingOffsetSrc;
                    uniform vec4 tilingOffsetDst;
            
                    varying vec2 v_texCoord;
            
                    void main() {
                        v_texCoord = a_texCoord * tilingOffsetSrc.xy + tilingOffsetSrc.zw;
                        gl_Position = vec4((a_position + 1.0) * tilingOffsetDst.xy - 1.0 + tilingOffsetDst.zw * 2.0, 0, 1);
                    }
*/
export let glsl_aa973a33df2c853535f347d69aa75cc4 = `
                    precision mediump float;

                    attribute vec2 a_position;
                    attribute vec2 a_texCoord;
            
                    uniform vec4 tilingOffsetSrc;
                    uniform vec4 tilingOffsetDst;
            
                    varying vec2 v_texCoord;
            
                    void main() {
                        v_texCoord = a_texCoord * tilingOffsetSrc.xy + tilingOffsetSrc.zw;
                        gl_Position = vec4((a_position + 1.0) * tilingOffsetDst.xy - 1.0 + tilingOffsetDst.zw * 2.0, 0, 1);
                    }
`
import {
    vec4_V2_N_N,
    sampler2D,
    samplerCube,
    float,
    float_N,
    bool,
    bool_N,
    int_N,
    int,
    vec4,
    vec3,
    vec2,
    mat2,
    mat3,
    mat4,
} from "../builtin/BuiltinFunc"
import {
    glSet_V2_V2,
    glMul_V2_V2,
    glAdd_V2_V2,
    glAdd_V2_N,
    glSub_V2_N,
    glMul_V2_N,
    glSet_V4_V4,
    getValueKeyByIndex,
    getOutValueKeyByIndex,
} from "../builtin/BuiltinOperator"
import {
    gl_FragData,
    gl_FragColor,
    gl_Position,
    gl_PointSize,
    gl_FragCoord,
    gl_FragDepth,
    gl_FrontFacing,
    custom_isDiscard,
} from "../builtin/BuiltinVar"
import { cpuRenderingContext } from "../../CpuRenderingContext"
import {
    AttributeData,
    FragShaderHandle,
    UniformData,
    VaryingData,
    ShaderLocalData,
    VertShaderHandle,
    StructData,
} from "../../ShaderDefine"
import {
    IntData,
    FloatData,
    Vec2Data,
    Vec3Data,
    Vec4Data,
    Mat2Data,
    Mat3Data,
    Mat4Data,
    BoolData,
    Sampler2D,
    SamplerCube,
} from "../builtin/BuiltinData"
class AttributeDataImpl implements AttributeData {
    a_position: Vec2Data = new Vec2Data()
    a_texCoord: Vec2Data = new Vec2Data()
    dataKeys: Map<string, any> = new Map([
        ["a_position", cpuRenderingContext.cachGameGl.FLOAT_VEC2],
        ["a_texCoord", cpuRenderingContext.cachGameGl.FLOAT_VEC2],
    ])
    dataSize: Map<string, number> = new Map([
        ["a_position", 1],
        ["a_texCoord", 1],
    ])
}
class VaryingDataImpl extends VaryingData {
    v_texCoord: Vec2Data = new Vec2Data()

    factoryCreate() {
        return new VaryingDataImpl()
    }
    dataKeys: Map<string, any> = new Map([["v_texCoord", cpuRenderingContext.cachGameGl.FLOAT_VEC2]])
    copy(varying: VaryingDataImpl) {
        glSet_V2_V2(varying.v_texCoord, this.v_texCoord)
    }
}
class UniformDataImpl implements UniformData {
    tilingOffsetSrc: Vec4Data = new Vec4Data()
    tilingOffsetDst: Vec4Data = new Vec4Data()
    dataKeys: Map<string, any> = new Map([
        ["tilingOffsetSrc", cpuRenderingContext.cachGameGl.FLOAT_VEC4],
        ["tilingOffsetDst", cpuRenderingContext.cachGameGl.FLOAT_VEC4],
    ])
    dataSize: Map<string, number> = new Map([
        ["tilingOffsetSrc", 1],
        ["tilingOffsetDst", 1],
    ])
}
class ShaderLocalDataImpl implements ShaderLocalData {
    dataKeys: Map<string, any> = new Map([])
    dataSize: Map<string, number> = new Map([])
    init() {}
}
export class Impl_aa973a33df2c853535f347d69aa75cc4 extends VertShaderHandle {
    varyingData: VaryingDataImpl = new VaryingDataImpl()
    uniformData: UniformDataImpl = new UniformDataImpl()
    attributeData: AttributeDataImpl = new AttributeDataImpl()

    main(): void {
        glSet_V2_V2(
            this.varyingData.v_texCoord,
            glAdd_V2_V2(
                glMul_V2_V2(this.attributeData.a_texCoord, this.uniformData.tilingOffsetSrc.xy),
                this.uniformData.tilingOffsetSrc.zw
            )
        )
        glSet_V4_V4(
            gl_Position,
            vec4_V2_N_N(
                glAdd_V2_V2(
                    glSub_V2_N(
                        glMul_V2_V2(glAdd_V2_N(this.attributeData.a_position, float_N(1.0)), this.uniformData.tilingOffsetDst.xy),
                        float_N(1.0)
                    ),
                    glMul_V2_N(this.uniformData.tilingOffsetDst.zw, float_N(2.0))
                ),
                int_N(0),
                int_N(1)
            )
        )
    }
}
